package com.dayu.web.controller.basic;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.basic.domain.BasicTestValues;
import com.dayu.basic.service.IBasicTestValuesService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

/**
 * 验机选项内容Controller
 * 
 * @author HK
 * @date 2021-04-15
 */
@RestController
@RequestMapping("/basic/testValues")
public class BasicTestValuesController extends BaseController
{
    @Autowired
    private IBasicTestValuesService basicTestValuesService;

    /**
     * 查询验机选项内容列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BasicTestValues basicTestValues)
    {
        startPage();
        List<BasicTestValues> list = basicTestValuesService.selectBasicTestValuesList(basicTestValues);
        return getDataTable(list);
    }

    /**
     * 导出验机选项内容列表
     */
    @PreAuthorize("@ss.hasPermi('basic:testValues:export')")
    @Log(title = "验机选项内容", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BasicTestValues basicTestValues)
    {
        List<BasicTestValues> list = basicTestValuesService.selectBasicTestValuesList(basicTestValues);
        ExcelUtil<BasicTestValues> util = new ExcelUtil<BasicTestValues>(BasicTestValues.class);
        return util.exportExcel(list, "testValues");
    }

    /**
     * 获取验机选项内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:testValues:query')")
    @GetMapping(value = "/{valuesId}")
    public AjaxResult getInfo(@PathVariable("valuesId") Long valuesId)
    {
        return AjaxResult.success(basicTestValuesService.selectBasicTestValuesById(valuesId));
    }

    /**
     * 新增验机选项内容
     */
    @PreAuthorize("@ss.hasPermi('basic:testValues:add')")
    @Log(title = "验机选项内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicTestValues basicTestValues)
    {
        return toAjax(basicTestValuesService.insertBasicTestValues(basicTestValues));
    }

    /**
     * 修改验机选项内容
     */
    @PreAuthorize("@ss.hasPermi('basic:testValues:edit')")
    @Log(title = "验机选项内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicTestValues basicTestValues)
    {
        return toAjax(basicTestValuesService.updateBasicTestValues(basicTestValues));
    }

    /**
     * 删除验机选项内容
     */
    @PreAuthorize("@ss.hasPermi('basic:testValues:remove')")
    @Log(title = "验机选项内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{valuesIds}")
    public AjaxResult remove(@PathVariable Long[] valuesIds)
    {
        return toAjax(basicTestValuesService.deleteBasicTestValuesByIds(valuesIds));
    }
}
